import { defineStore } from "pinia";
import { type CateLiftData, type bannerList5,type categoryGroupList,type itemList, getCateLiftList,getcateList,getCateShopList } from '@/api/cate';

interface CateStoreData {
    cate1List:CateLiftData[],
    bannerList1:bannerList5[],
    cate1Id:string | number,
    categoryGroupList:categoryGroupList[],
    ImageList:bannerList5[],
    itemList:itemList[]
}

export const useCateStore = defineStore('cate',{
    state():CateStoreData{
        return{
            cate1List:[],
            bannerList1:[],
            cate1Id:'',
            categoryGroupList:[],
            ImageList:[],
            itemList:[]
        }
    },
    actions:{
        async getCateL1List() {
            try {
                const result = await getCateLiftList()
                console.log(result);
                this.cate1List = result.data.categoryL1List || []
            } catch (error) {
                alert('拿不到了')
                return Promise.reject(error)
            }
        },
        async getPagingListdData(id:number){
            try {
               const result = await getcateList(id)
               this.categoryGroupList = result.data.categoryGroupList as [] || []
               
               this.ImageList = result.data.currentCategory.bannerList as [] || []
    
            //    console.log(result)
            } catch (error) {
                return Promise.reject(error)
            }
         }
    },
    getters:{}
})